package com.google.gwt.mobile.phonegap.api;

/**
 * The Class Event.
 */
public class Event {

  /**
   * The Interface Callback.
   */
  public interface Callback {

    /**
     * On event fired.
     */
    public void onEventFired();
  }

  /**
   * On device ready.
   * 
   * @param callback the callback
   */
  public native static void onDeviceReady(Callback callback) /*-{
		$doc
				.addEventListener(
						"deviceready",
						function() {
							callback.@com.google.gwt.mobile.phonegap.api.Event.Callback::onEventFired()();
						}, false);
  }-*/;

  /**
   * On pause.
   * 
   * @param callback the callback
   */
  public native static void onPause(Callback callback) /*-{
		$doc
				.addEventListener(
						"pause",
						function() {
							callback.@com.google.gwt.mobile.phonegap.api.Event.Callback::onEventFired()();
						}, false);
  }-*/;

  /**
   * On resume.
   * 
   * @param callback the callback
   */
  public native static void onResume(Callback callback) /*-{
		$doc
				.addEventListener(
						"resume",
						function() {
							callback.@com.google.gwt.mobile.phonegap.api.Event.Callback::onEventFired()();
						}, false);
  }-*/;

  // below are Android specific events.

  /**
   * On back button.
   * 
   * @param callback the callback
   */
  public native static void onBackButton(Callback callback) /*-{
		$doc
				.addEventListener(
						"backbutton",
						function() {
							callback.@com.google.gwt.mobile.phonegap.api.Event.Callback::onEventFired()();
						}, false);
  }-*/;

  /**
   * On menu button.
   * 
   * @param callback the callback
   */
  public native static void onMenuButton(Callback callback) /*-{
		$doc
				.addEventListener(
						"menubutton",
						function() {
							callback.@com.google.gwt.mobile.phonegap.api.Event.Callback::onEventFired()();
						}, false);
  }-*/;

  /**
   * On search button.
   * 
   * @param callback the callback
   */
  public native static void onSearchButton(Callback callback) /*-{
		$doc
				.addEventListener(
						"searchbutton",
						function() {
							callback.@com.google.gwt.mobile.phonegap.api.Event.Callback::onEventFired()();
						}, false);
  }-*/;
}
